package org.jsea.meta.api.service.fmt;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * --.
 * *
 * author   Jiang.hy
 * create   2023-03-17
 */
public class MetaApiArrayFormat extends MetaApiValueFormat {

    private final String pattern;

    public MetaApiArrayFormat(String pattern) {
        this.pattern = pattern;
    }

    @Override
    protected Object doparse(String text) throws Exception {
        if (pattern == null || pattern.isEmpty()) {
            return mapper.readValue(text, ArrayList.class);
        }
        //使用List，后续有集合的判断
        return Arrays.asList(text.split(pattern));
    }
}
